# /usr/bin/python
# -*- coding: utf-8 -*-

import pymysql

conn = pymysql.connect(host="10.205.140.42",port=3306,user="mysql",passwd="mysql888",db="falcon_portal")
cur = conn.cursor()

cur.execute("SELECT * FROM cluster WHERE endpoint='nginx_status_count'")
result = cur.fetchall()
for item in result:
    print item
    domain = item[6].split('=')[1]
    cmd = "INSERT INTO cluster VALUES (null,585,'%s','%s','%s','%s','%s','GAUGE',60,null,'root')"\
            %(item[2],item[3],domain,item[5],'')
    cur.execute(cmd)

conn.commit()
conn.close()